package com.example.yiwu;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import com.avos.avoscloud.AVUser;

public class ChoiceActivity extends Activity {

    private Button mToLogin;
    private Button mToSignup;

    @Override
    public void  onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
/**
 * *******************************************************************************************
 *    系统状态栏透明化代码
 */
        getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                    | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
            window.setNavigationBarColor(Color.TRANSPARENT);
        }
/**
 * ********************************************************************************************
 */
        setContentView(R.layout.activity_choices);


        if (AVUser.getCurrentUser() != null) {
            startActivity(new Intent(ChoiceActivity.this, WelcomeActivity.class));
            ChoiceActivity.this.finish();
        }

        mToLogin = (Button) findViewById(R.id.to_login);
        mToSignup = (Button) findViewById(R.id.to_register);
        mToLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent mainIntent = new Intent(ChoiceActivity.this, LoginActivity.class);
                startActivity(mainIntent);
//                ChoiceActivity.this.finish();
            }
        });
        mToSignup.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent mainIntent = new Intent(ChoiceActivity.this, RegisterActivity.class);
                startActivity(mainIntent);
//                ChoiceActivity.this.finish();
            }
        });
    }

    @Override
    public void onBackPressed() {

        android.support.v7.app.AlertDialog.Builder
                builder=new android.support.v7.app.AlertDialog.Builder(this);
        builder.setTitle("提示");
        builder.setMessage("您滚不滚？");
        builder.setNegativeButton("不滚", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        builder.setPositiveButton("滚", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                ChoiceActivity.this.finish();
            }
        });
        builder.show();
        //super.onBackPressed();
    }
}
